import subprocess

def dig_dns(dns_ip,domain):
    for _ in range(2):
        try:
            retcode = subprocess.check_output(['dig','+short',dns_ip,domain,'A'],timeout=10)
            # print(help(retcode))
            ret_list = retcode.decode('utf8')
            if ret_list:
                ret_list = ret_list.split('\n')[0:-1]
            return ret_list
        except subprocess.TimeoutExpired:
            pass
        except subprocess.CalledProcessError:
            pass
    return None
